package com.gjzhao.fmmall.service.juc;

import java.util.concurrent.TimeUnit;

/**
 * @Description: 测试测试是守护线程
 * @Author: gjzhao
 * @Date Created in 2022-03-05 10:50 下午
 */
public class TestIsDaemonThread {

    public static void main(String[] args) {

        new Thread(() -> {

            System.out.println("--- 当前线程为:" + (Thread.currentThread().isDaemon() ? "守护线程 " : "用户线程"));

            try {
                TimeUnit.SECONDS.sleep(3);

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "A线程").start();


        System.out.println("--- main线程为:" + (Thread.currentThread().isDaemon() ? "守护线程 " : "用户线程"));
    }
}
